<?php

$host="koios";
$user="gsdbadmin";
$pass="atdt911";
$db="gsdata";

$dblink = @mysql_connect($host,$user,$pass);

mysql_select_db($db,$dblink);

$id=$_GET['id'];

#$query="SELECT * FROM weapon WHERE id = '$id'";
$query= <<<QUERY
SELECT weapon.idweapon, weapon.name, ammo_dmg.caliber,wpntype.name,
weapon.class, weapon.hands, weapon.dmgtype, weapon.range, weapon.error,
weapon.threat, weapon.rate, weapon.reqstr, weapon.reqdex, weapon.capacity,
weapon.mags, ammo.abbr, weapon.pic, weapon.complexity, weapon.cost,
weapon.restrict,
trait1.abbr, trait2.abbr, trait3.abbr, weapon.conceal, weapon.desc,
weapon.terse, weapon.adjectives, weapon.synonyms, weapon.uuid,
weapon.dur_curr, weapon.dur_max, weapon.upgrades
FROM weapon
JOIN wpntype ON weapon.idwpntype = wpntype.idwpntype
JOIN ammo_dmg ON weapon.idcaliber = ammo_dmg.idammo_dmg
JOIN ammo ON weapon.idammo = ammo.idammo
LEFT JOIN trait trait1 ON weapon.idtrait1 = trait1.idtrait
LEFT JOIN trait trait2 ON weapon.idtrait2 = trait2.idtrait
LEFT JOIN trait trait3 ON weapon.idtrait3 = trait3.idtrait
WHERE weapon.idweapon = $id;
QUERY;

$result = mysql_query($query);
$num = mysql_numrows($result);

mysql_close();

$i = 0;
while($i < $num) {
	$name = mysql_result($result,$i,"name");
	
	$i++;
}



?>

<html>
<body>
SQL Query: <?php echo $query ?><p/>

<div class="gs-tooltipReturn">
<input type="hidden" name="currentID" value="<?php echo $id ?>">
Weapon name: <?php echo $name; ?>
</div>

</body>
</html>
